﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LightEngine
{
    namespace Mathematics
    {

        public class DegreeDefining
        {
            private const Double Basis = 10.0;
            public static Int32 NumberExponent(Double Number)
            {
                return (Number < 1.0) == true ? FindNegativeDegree(Number) : FindPositiveDegree(Number);
            }

            private static Int32 FindPositiveDegree(Double Number)
            {
                Int32 Degree = 0;
                if (Number == 1.0) return Degree;
                while (Number / Basis >= 1.0)
                {
                    Number /= Basis;
                    Degree++;
                }
                return Degree;
            }

            private static Int32 FindNegativeDegree(Double Number)
            {
                Int32 Degree = 0;
                while (Number * Basis < Basis)
                {
                    Number *= Basis;
                    Degree--;
                }
                return Degree;
            }
        }
    }
}

